<template>
    <div>
        <el-drawer custom-class="wxkj-drawer content-management-edit-drawer" :title="drawerTitle" :visible.sync="drawerShow" size="500px">
            <div class="drawer-content">
                <el-form ref="form" :model="form" label-width="100px">




                  <el-form-item label="请求类型："  >
                    <span>{{ form.requestType }}</span>
                  </el-form-item>
                  <el-form-item label="请求方法：" >
                    <span>{{ form.method }}</span>
                  </el-form-item>
                  <el-form-item label="请求参数："  >
                    <span>{{ form.requestParam }}</span>
                  </el-form-item>
                  <el-form-item label="请求URL：" >
                    <span>{{ form.requestUrl }}</span>
                  </el-form-item>
                  <el-form-item label="耗时："  >
                    <span>{{ form.costTime }}毫秒</span>
                  </el-form-item>
                  <el-form-item label="IP：" >
                    <span>{{ form.ip }}</span>
                  </el-form-item>
                  <el-form-item label="创建时间：" >
                    <span>{{ form.createTime }}</span>
                  </el-form-item>
                  <el-form-item label="操作人ID："  >
                    <span>{{ form.userid }}</span>
                  </el-form-item>
                  <el-form-item label="姓名："  v-show="null!=form.realname">
                    <span>{{ form.realname }}</span>
                  </el-form-item>
                  <el-form-item label="手机号：" v-show="null!=form.phone">
                    <span>{{ form.phone }}</span>
                  </el-form-item>




<!--                    <el-form-item label="菜单路径：" prop="url">-->
<!--                        <el-input v-model="form.url" />-->
<!--                    </el-form-item>-->
<!--                   <el-form-item label="菜单图标："   v-show="1==form.menuType">-->
<!--                       <el-col :span="18">-->
<!--                          <el-input placeholder="请选择图标" v-model="form.icon" />-->
<!--                        </el-col>-->
<!--                        <el-col :span="6" class="pl20">-->
<!--                          <el-button  @click="selectIcon"   >选择</el-button>-->
<!--                        </el-col>-->
<!--                  </el-form-item>-->
<!--                  <el-form-item label="菜单排序：" prop="publishTime">-->

<!--                    <el-input-number v-model="form.sortNo"   :min="0" :max="100" label=""></el-input-number>-->
<!--                  </el-form-item>-->
                    <div class="drawer-form-buttom-group">


                        <el-button type="primary"  @click="drawerClose">关闭</el-button>
                    </div>
                </el-form>
            </div>
        </el-drawer>
        <icon  ref="icon" @icon="selectedIcon"/>
    </div>
</template>

<script>
    //import tinymceEditor from "@/components/Tinymce";
    //import uploadCropper from "@/components/uploadCropper";
    import {sys_user_queryById} from "@/api/sys_user";
    import icon from "@/components/IconDialog";
    import {menu_delete} from "@/api/sys_menu";


    export default {
        components: {icon},

        data() {

            return {


                drawerShow: false,
                drawerTitle: "",
                thumb_dictText: "", // 展示缩略图使用
                 sysUser:null,
                form: {

                }

            };
        },
        watch: {
            drawerShow(bl) {
                if (!bl) {
                    // this.thumb_dictText = "";
                    // this.form.content = "";
                    this.$refs.form.resetFields();
                    // this.$refs.editor.setContent("");
                    // this.$refs.uploadCropper.initUpload();
                }
            },
        },
        // 生命周期 - 创建完成（可以访问当前this实例）
        created() {



        },
        // 生命周期 - 挂载完成（可以访问DOM元素）
        mounted() {},
        // 销毁
        destroyed() {},
        // 方法
        methods: {
          selectIcon(){
          //  console.log(1111)
            this.$refs.icon.show()
          },
        selectedIcon(icon){
          this.form.icon = icon;
        },

            // 关闭弹窗
            drawerClose() {
                this.drawerShow = false;
                this.$emit("refresh");
            },
          // 弹窗打开
          show(title,  rowData) {
              // this.topBlockId=topBlockId;
              this.drawerTitle = title
              this.drawerShow = true
              // console.log(rowData);
              if(null!=rowData){
                // 编辑传参
                try {
                  if (rowData) {
                    Object.keys(rowData).forEach(k => {
                      this.form[k] = rowData[k]
                     // console.log(k,this.form[k]);
                    })
                  }
                } catch (e) {
                  // TODO handle the exception
                }


                console.log("=====userid=======",rowData.userid)
                if(''==rowData.userid) rowData.userid=null;
                //rowData.userid='51121';
                if(null!=rowData.userid){
                  sys_user_queryById({"id":rowData.userid}).then(response => {
                    this.sysUser=response.result;
                     if(null== this.sysUser){
                       this.form.phone=null;
                       this.form.realname=null;
                     }else {
                       this.form.phone=this.sysUser.phone;
                       this.form.realname=this.sysUser.realname;
                     }
                    // rowData.realname=user.realname;
                    // rowData.phone=user.phone;


                  })
                }

              }else {//新增

              }



          }//end of show




        },
    };
</script>
<style lang="scss">
    .content-management-edit-drawer {
        .drawer-content {
            padding: 20px;

            .upload-img {
                .el-upload {
                    width: 200px;
                    height: 100px;
                    line-height: 110px;
                }
            }
        }
    }
</style>
